using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using Tomahawk.Runtime.Screen.Controls;

namespace Tomahawk.Runtime.Screen.Controls
{
    /// <summary>
    /// This class represent a menu option. 
    /// It's implemented as a TextTile with an extra color for the selected state
    /// </summary>
    public class MenuOption : TextTile
    {
        private Color selectedTextColor = Color.Green;

        /// <summary>
        /// Gets/Sets the color of the text when the option is selected
        /// </summary>
        public Color SelectedTextColor
        {
            get { return this.selectedTextColor; }
            set { this.selectedTextColor = value; }
        }

        private string name;

        /// <summary>
        /// Returns the name of the option.
        /// You can use this to identife this option as the selected one
        /// </summary>
        public string Name
        {
            get { return name; }
        }

        private bool selected;

        /// <summary>
        /// Determine if the current option is selected
        /// </summary>
        public bool Selected
        {
            get { return selected; }
            set { selected = value; }
        }

        /// <summary>
        /// Constructor
        /// </summary>
        public MenuOption(string name, string caption, Color normalColor, Color selectedColor)
        {
            this.name = name;
            this.TextColor = normalColor;
            this.selectedTextColor = selectedColor;
            this.Caption = caption;
        }

        /// <summary>
        /// Render the selected texture when the menu option is selected
        /// </summary>
        protected override void OnRender(GraphicsDevice device, SpriteBatch spriteBatch)
        {
            if (this.selected)
            {
                Rectangle rect = this.Rect;
                spriteBatch.DrawString(font, Caption, new Microsoft.Xna.Framework.Vector2(rect.Left + this.shadowDisplacement.X, rect.Top + this.shadowDisplacement.Y), this.shadowColor);
                spriteBatch.DrawString(font, Caption, new Microsoft.Xna.Framework.Vector2(rect.Left, rect.Top), this.selectedTextColor);
            }
            else
                base.OnRender(device, spriteBatch);
        }

    }

}


